# finally: 表示无论是否异常都要执行的代码 -- 例如：关闭文件
try:
    f = open('test1.txt','r')
except Exception as e:
    print(e)
    f = open('test1.txt','w')
else:
    print('没有异常，真开心')
finally:
    f.close()